#include <cstdio>
#include <algorithm>

using namespace std;

struct Node
{
    int d, h;
};

bool operator < ( const Node &a, const Node &b )
{
    return a.h * b.d < a.d * b.h;
}

Node a[ 100 ];

int main( )
{
    int n, i, sumd;
    long long ans;
    while ( scanf("%d", &n) != EOF )
    {
        sumd = 0;
        for ( i = 0; i < n; i++ )
        {
            scanf("%d%d", &a[ i ].d, &a[ i ].h);
            sumd += a[ i ].d;
        }
        sort( a, a + n );
        ans = 0;
        for ( i = 0; i < n; i++ )
        {
            ans += sumd * a[ i ].h;
            sumd -= a[ i ].d;
        }
        printf("%I64d\n", ans);
    }
    return 0;
}
